/*
 * @Description 
 * @Autor lzhiqiang
 * @Date 2023-04-03 14:33:55
 * @LastEditors lzhiqiang
 * @LastEditTime 2023-04-05 16:37:41
 */
#ifndef __APPLICATION_H__
#define __APPLICATION_H__

#include "iomanager.h"
#include "http/http_server.h"
#include "http/ws_server.h"
#include "address.h"
#include "module.h"

#include "env.h"
#include "log.h"
#include "config.h"
#include "daemon.h"
#include "tcp_server.h"
#include "address.h"
#include "worker.h"
#include "module.h"

namespace johnsonli
{
    class Application
    {
    public:
        Application();

        bool init(int argc, char** argv);
        bool run(Module::ptr module = nullptr);

        static Application* GetInstance() { return s_instance;}

        bool getServer(const std::string& type, std::vector<TcpServer::ptr>& svrs);
        
    private:

        // 子进程运行
        int main(int argc, char** argv, Module::ptr module = nullptr);
        // 协程
        void run_fiber(Module::ptr module = nullptr);

    private:
        int m_argc = 0;
        char** m_argv = nullptr;

        static Application* s_instance;

        //std::vector<johnsonli::http::HttpServer::ptr> m_httpserver;
        std::map<std::string, std::vector<TcpServer::ptr> > m_servers;
        IOManager::ptr m_mainIOManager;

    };
}


#endif
